home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
ddj0897.zip
/
DYN401.ZIP
/
bin
/
delcr.c
< prev
Wrap
C/C++ Source or Header
|
1995-08-08
|
866b
|
54 lines
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifndef MSDOS
#define RMODE "r"
#define WMODE "w"
#else
#define RMODE "rb"
#define WMODE "wb"
#endif
static void copy(FILE *ffp, FILE *tfp);
main(int argc, char *argv[])
{
FILE *ffp, *tfp;
char *ffile, tfile[20];
strcpy(tfile, "tfXXXXXX");
mktemp(tfile);
while (--argc) {
if (NULL == (ffp = fopen(ffile=*++argv, RMODE))) {
fprintf(stderr, "Can't open %s\n", ffile);
continue;
}
if (NULL == (tfp = fopen(tfile, WMODE))) {
fprintf(stderr, "Can't create %s\n", tfile);
fclose(ffp);
continue;
}
copy(ffp, tfp);
fclose(ffp);
fclose(tfp);
unlink(ffile);
rename(tfile, ffile);
}
}
static void copy(FILE *ffp, FILE *tfp)
{
register int c;
while (1) {
c = getc(ffp);
if (c == EOF && feof(ffp))
return;
if (c != '\r' && c != 26)
putc(c, tfp);
}
}